package com.eop.service.impl;

import java.util.Date;
import java.util.List;

import com.eop.dao.IEventDao;
import com.eop.entity.Event;
import com.eop.service.IEventService;

public class EventServiceImpl implements IEventService {
	private IEventDao eventDao;

	public IEventDao getEventDao() {
		return eventDao;
	}

	public void setEventDao(IEventDao eventDao) {
		this.eventDao = eventDao;
	}

	@Override
	public void deleteEvent(Event sr) {
		eventDao.delete(sr);
	}

	@Override
	public List<Event> getAllEvent() {

		return eventDao.findAllByNamedQuery("sr.getAllEffectEvent");
	}

	@Override
	public Event getEventById(String id) {

		return eventDao.getById(id);
	}

	@Override
	public List<Event> getEventByName(String srName) {

		return eventDao.findAllByNamedQuery("sr.getEventByName", "%"+srName+"%");
	}

	@Override
	public void saveEvent(Event sr) {
		eventDao.saveOrUpdate(sr);
	}

	@Override
	public List<Event> getAllEffectEvent() {
		return eventDao.findAllByNamedQuery("sr.getAllEffectEvent");
	}

	@Override
	public List<Event> getEventByDate(Date startDate, Date endDate) {
		// TODO Auto-generated method stub
		return eventDao.findAllByNamedQuery("sr.getEvent",startDate,endDate);
	}

}
